;; Set personalized variables
(setq user-full-name "Corey Oliver")
(setq user-mail-address "corey.jon.oliver@gmail.com")

;; Set UTF-8 as the preferred encoding method
(prefer-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)

;; Adjust compilation window size
(setq compilation-window-height 8)

;; Change the location where backup files are placed. Instead of
;; being spread out all over the filesystem, they're now placed in one
;; location.
(if (file-accessible-directory-p (expand-file-name
				  "~/.local/share/Trash/files"))
    (add-to-list 'backup-directory-alist
		 (cons "." (expand-file-name 
			    "~/.local/share/Trash/files/emacs-backups/"))))

;; Prevent compilation windows from staying up if successful
(setq compilation-finish-function
      (lambda (buf str)
        (if (string-match "exited abnormally" str)
            ;;there were errors
            (message "compilation errors, press C-x ` to visit")
          ;;no errors, make the compilation window go away in 0.5 seconds
          (run-at-time 0.5 nil 'delete-windows-on buf)
          (message "NO COMPILATION ERRORS!"))))

;; Replace "yes or no" with y or n
(defun yes-or-no-p (arg)
  (y-or-n-p arg))

;; Shut off annoying beep. Keep it on only for special situations
(setq visible-bell t)

(emacs-control-reset) ;; Set some defaults (see efunc.el)

;; Automatically parses an archive when opened, and lets you
;; selectively open files
(auto-compression-mode 1)

;; Set extension and mode associations
(setq auto-mode-alist
      (append '(("\\.[Cc][Xx][Xx]$" . c++-mode)
                ("\\.[Cc][Pp][Pp]$" . c++-mode)
                ("\\.[Hh][Xx][Xx]$" . c++-mode)
                ("\\.[Tt][Cc][Cc]$" . c++-mode)
                ("\\.h$" . c++-mode)
                ("_emacs" . lisp-mode)
                ("\\.el\\.gz$" . lisp-mode)
                ("\\.mak$" . makefile-mode)
                ("\\.conf$" . conf-mode)
                ("Doxyfile.tmpl$" . makefile-mode)
                ("Doxyfile$" . makefile-mode)
		("\\.org$" . org-mode)
                ("\\.scons$" . python-mode)
                ("SCons\\(cript\\|truct\\)" . python-mode)
                ("\\.gclient$" . python-mode)
		("\\.php$" . php-mode)
		("\\.inc$" . php-mode)
		("\\.xml$" . nxml-mode)
		("\\.gp$" . gnuplot-mode)
		("\\.ly$" . LilyPond-mode)
		("\\.ily$" . LilyPond-mode)
		("\\.js$" . javascript-mode)
		("\\.as$" . actionscript-mode)
		("\\.dot$" . graphviz-dot-mode)
                ) auto-mode-alist))

;; Enable undo-browser (even I can make mistakes)
;; (require 'undo-browse)
;; (ub-install-deego)